<?php
// $Id$

/**
 * Controller_Admin_Union 控制器
 */
class Controller_Admin_Union extends Controller_Abstract
{

	function actionIndex()
	{
		if ($_SESSION['acct']['discharge_level'] != 1){
			exit('只有流量模式用户才可使用');
		}
        // 为 $this->_view 指定的值将会传递数据到视图中
		# $this->_view['text'] = 'Hello!';
		if($this->_context->isPOST())
		{
			$setlv1 = floatval($this->_context->setlv1);
			if(!QValidator::validate_between($setlv1, 0, 100))
			{
				return $this->error('比例必须在0-100%以内');
			}
			$acct = acct::find('id = ? and acctname = ?',$_SESSION['acct']['id'],$_SESSION['acct']['acctname'])->getone();
			if(!$acct->unionset->id)
			{
				$union = new Acctextension();
				$union->acctid = $acct->id;
				$union->set_lv1 = $setlv1;
				$union->save(0,'create');
			}else{
				$union = $acct->unionset;
				$union->set_lv1 = $setlv1;
				$union->save(0,'update');
			}
			return $this->success('设置成功');
		}
	}
	function actionlog()
	{
		if($_SESSION['acct']['acclevel'] == 0)
		{
			$param = null;
		}else{
			$param = array('unionuser' => $_SESSION['acct']['acctname']);
		}
		$this->union_table = Unionpaylog::meta();
		$this->lists($param);
	}
	function actionview()
	{
		
	}
	
}


